<template>
	<view class="user">
		<view class="top">
			<image src="../../static/images/history.png" mode=""></image>
			<view claas="text">浏览历史</view>
		</view>
		<view class="content" >
			<view class="row" v-for="item in listArr">
				<newsbox :item="item" @click.native="getUrl(item)"></newsbox>
			</view>
		</view>
		<view class="nohis" v-if="!listArr.length">
			<image src="../../static/images/nohis.png" mode="widthFix"></image>
			<text class="text">暂无浏览记录</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				listArr: []
			}
		},
		onShow() {
			this.getdata()
		},
		methods: {
			getdata() {
				let historyArr = uni.getStorageSync('historyArr') || []
				this.listArr = historyArr
			},
			getUrl(item) {
				uni.navigateTo({
					url: `/pages/detail/detail?cid=${item.classid}&id=${item.id}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.user {
		.top {
			padding: 50rpx 0;
			background: #f8f8f8;
			color: #555;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			image {
				width: 150rpx;
				height: 150rpx
			}

			.tetx {
				font-size: 38rpx;
				padding-top: 20rpx;
			}
		}

		.content {
			padding: 30rpx;

			.row {
				border-bottom: 1px dashed #efefef;
				padding: 15rpx 0;
			}
		}
		.nohis{
			display: flex;
			flex-direction: column;
			font-size: 20rpx;
			align-items: center;
			color:#888;
			image{
				width: 400rpx;
			}
		}
	}
</style>
